class Solution {
public:
 int minEditCost(string str1, string str2, int ic, int dc, int rc) {
     // write code here
     if(str1.size()+str2.size() == 0)
     return 0;
     int len1 = str1.size(), len2 = str2.size();
     if(len1 == 0 || len2 == 0)
         return max(len1, len2);
     // 动规数组
     vector<vector<int>> vv(len1+1, vector<int>(len2+1, 0));
     // 初始化首行首列
     for(int i = 0; i <= len1; ++i)
         vv[i][0] = i*dc;   // 第0列,str1如何编辑成空串（删除）
     for(int j = 0; j <= len2; ++j)
         vv[0][j] = j*ic;  // 第0行，空串如何变成str2（插入）
     
     for(int i = 1; i <= len1; ++i){
         for(int j = 1; j <= len2; ++j){
             if(str1[i-1] == str2[j-1]){
                 vv[i][j] = vv[i-1][j-1];
             }
             else{
                 vv[i][j] = vv[i - 1][j - 1] + rc;
                 vv[i][j] = min(vv[i][j], vv[i][j - 1] + ic);
                 vv[i][j] = min(vv[i][j], vv[i - 1][j] + dc);
             }
         }
     }
     return vv[len1][len2];
 }
};